package com.eqdd.yiqidian.utils;

import android.support.annotation.LayoutRes;

import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.adapter.slimadapter.SlimAdapterEx;
import com.eqdd.yiqidian.adapter.slimadapter.SlimInjector;
import com.eqdd.yiqidian.adapter.slimadapter.viewinjector.IViewInjector;
import com.eqdd.yiqidian.bean.rebuild.CarAccidentListBean;
import com.eqdd.yiqidian.bean.rebuild.CarInsuranceListBean;
import com.eqdd.yiqidian.bean.rebuild.CarPaperListBean;
import com.eqdd.yiqidian.bean.rebuild.CarRecordInfoBean;
import com.eqdd.yiqidian.bean.rebuild.CarUseListBean;
import com.eqdd.yiqidian.bean.rebuild.CarViolationListBean;
import com.eqdd.yiqidian.bean.rebuild.RenliListBean;
import com.eqdd.yiqidian.bean.rebuild.TrainListBean;
import com.eqdd.yiqidian.bean.rebuild.TrainNoticeListBean;
import com.eqdd.yiqidian.bean.rebuild.TrainPlanListBean;

/**
 * @author吕志豪 .
 * @date 17-11-24  下午3:15.
 * Github :https://github.com/lvzhihao100
 * E-Mail：1030753080@qq.com
 * 简书 :http://www.jianshu.com/u/6e525b929aac
 */

public class SlimUtil {
    public static SlimAdapterEx layout(SlimAdapterEx slimAdapterEx, @LayoutRes int layoutId, Class clazz) {
        return layout(slimAdapterEx, layoutId, clazz, 0);
    }

    public static SlimAdapterEx layout(SlimAdapterEx slimAdapterEx, @LayoutRes int layoutId, Class clazz, int type) {
        if (slimAdapterEx == null) {
            System.out.println("slim不能为空");
            return null;
        }
        switch (layoutId) {
            case R.layout.list_item_12:
                if (clazz == CarPaperListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<CarPaperListBean>() {
                                @Override
                                public void onInject(CarPaperListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, "申请人名字:" + data.getApplyerName())
                                            .text(R.id.tv_upper_right_content, data.getPlateNumber())
                                            .text(R.id.tv_down_left_content, data.getOrigin() + "到" + data.getDestination())
                                            .text(R.id.tv_down_right_content, data.getStartTime() + "~" + data.getEndTime());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == CarRecordInfoBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<CarRecordInfoBean>() {
                                @Override
                                public void onInject(CarRecordInfoBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, data.getCreaterName())
                                            .text(R.id.tv_upper_right_content, data.getPlateNumber())
                                            .text(R.id.tv_down_right_content, data.getCost() + "元")
                                            .text(R.id.tv_down_left_content, data.getType());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == CarViolationListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<CarViolationListBean>() {
                                @Override
                                public void onInject(CarViolationListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, data.getCreaterName())
                                            .text(R.id.tv_upper_right_content, data.getPlateNumber())
                                            .text(R.id.tv_down_right_content, data.getCreateTime())
                                            .text(R.id.tv_down_left_content, "责任人:" + data.getPersonLiableName());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == CarAccidentListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<CarAccidentListBean>() {
                                @Override
                                public void onInject(CarAccidentListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, data.getCreaterName())
                                            .text(R.id.tv_upper_right_content, data.getPlateNumber())
                                            .text(R.id.tv_down_right_content, data.getCreateTime())
                                            .text(R.id.tv_down_left_content, "责任人:" + data.getPersonLiableName());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == CarInsuranceListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<CarInsuranceListBean>() {
                                @Override
                                public void onInject(CarInsuranceListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, data.getCreaterName())
                                            .text(R.id.tv_upper_right_content, data.getPlateNumber())
                                            .text(R.id.tv_down_right_content, data.getCreateTime())
                                            .text(R.id.tv_down_left_content, "代理人:" + data.getAgent());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == CarUseListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<CarUseListBean>() {
                                @Override
                                public void onInject(CarUseListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, "申请人" + data.getApplyerName())
                                            .text(R.id.tv_upper_right_content, data.getPlateNumber())
                                            .text(R.id.tv_down_right_content, data.getCreateTime())
                                            .text(R.id.tv_down_left_content, "目的地:" + data.getDestination());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == RenliListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<RenliListBean>() {
                                @Override
                                public void onInject(RenliListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, "申请人" + data.getPostName())
                                            .text(R.id.tv_upper_right_content, "需" + data.getRecruitRenShu() + "人")
                                            .text(R.id.tv_down_left_content, "要求" + data.getDemandAtWorkTime() + "到岗")
                                            .text(R.id.tv_down_right_content, data.getCreateTime());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == TrainListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<TrainListBean>() {
                                @Override
                                public void onInject(TrainListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, "主题:" + data.getTheTheme())
                                            .text(R.id.tv_upper_right_content, "类别:" + data.getTheCategory())
                                            .text(R.id.tv_down_left_content, "预算:" + data.getBudgetedExpense() + "元")
                                            .text(R.id.tv_down_right_content, data.getThedateStart() + "~" + data.getThedateEnd());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == TrainPlanListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<TrainPlanListBean>() {
                                @Override
                                public void onInject(TrainPlanListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, "主题:" + data.getTheTheme())
                                            .text(R.id.tv_upper_right_content, "类别:" + data.getTheCategory())
                                            .text(R.id.tv_down_left_content, data.getFinishTime() + "结束")
                                            .text(R.id.tv_down_right_content, data.getCompletionRate());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else if (clazz == TrainNoticeListBean.class) {
                    switch (type) {
                        case 0:
                            return slimAdapterEx.register(R.layout.list_item_12, new SlimInjector<TrainNoticeListBean>() {
                                @Override
                                public void onInject(TrainNoticeListBean data, IViewInjector injector) {
                                    injector.text(R.id.tv_upper_left_content, "主题:" + data.getTheTheme())
                                            .text(R.id.tv_upper_right_content, "讲师:" + data.getTeacherName())
                                            .text(R.id.tv_down_left_content, data.getTheplace())
                                            .text(R.id.tv_down_right_content, data.getTrainees());
                                }
                            });

                        default:
                            System.out.println("该布局未实现");
                            return null;
                    }
                } else {
                    System.out.println("该布局未实现");
                    return null;
                }
            default:
                System.out.println("该布局未实现");
                return null;
        }
    }
}
